log using Analyseslog , replace


clear all
cls

global erg "..\Results\Final"
use "Allbus_bulayouth_sec_Mar23.dta", clear // data coded in DataPreparation.do

*used packages
search st0085_2 // install manually
ssc install catplot, replace
ssc install cm2in, replace
ssc install reghdfe, replace
ssc install ftools, replace
ssc install coefplot, replace
ssc install estwrite, replace

***
*In this file:
*****
***Step 0a: Descriptive Univariate Distributions of political DVs.
***Step 0b: Descriptives: Association: Edu - Engagement
***Step 1 : Main Analyses
***Step 1b: Main Analyses as Table
***Step 2 : Analyses for single dependent variables , no indices
***Step 3 : Analyses for individual destratifying policies (that build together the index) (2-level) & categorical index
***Step 4 : Analyses for additional societal groups (Parental occupational qualification and respondents' oesch class) 
***Step 5 : Alternative Modelling Strategies
***Step 6: Cross-Level Interaction with Individual Level and Cross-Level confounding and mediation
***Step 7 : Main Analyses for full time employees 



***********************************************************************************************************************************************************
****************************Step 0a: Descriptive Univariate Distributions of political DVs.s***************************************************************
***********************************************************************************************************************************************************



*****
***
*Step 0a: Univariate Distributions (Tabules)
***
*****

estpost summarize part1 polint peff 
esttab using "$erg\Appendix\Descriptives_DepVars.tex" , cell((count mean(fmt(2)) sd(fmt(2)) min max)) label replace  prehead(`"{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabulary}{\textwidth}{J R R R R R R R} \hline\hline "') postfoot(`"\hline\hline \end{tabulary}}"') b(2) nonumbers 

estpost summarize convp1  elect wrkprty protvote abstain 
esttab using "$erg\Appendix\Descriptives_DepVars_ConvP.tex" , cell((count mean(fmt(2)) sd(fmt(2)) min max)) label replace  prehead(`"{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabulary}{\textwidth}{J R R R R R R R} \hline\hline "') postfoot(`"\hline\hline \end{tabulary}}"') b(2) nonumbers 

estpost summarize unconvp  opinion  discuss initiv unlawdem demo petition  
esttab using "$erg\Appendix\Descriptives_DepVars_UnconvP.tex" , cell((count mean(fmt(2)) sd(fmt(2)) min max)) label replace  prehead(`"{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabulary}{\textwidth}{J R R R R R R R} \hline\hline "') postfoot(`"\hline\hline \end{tabulary}}"') b(2) nonumbers 

estpost summarize intpeff peactgrp_rev pecomplx peknowl   
esttab using "$erg\Appendix\Descriptives_DepVars_Intpeff.tex" , cell((count mean(fmt(2)) sd(fmt(2)) min max)) label replace  prehead(`"{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabulary}{\textwidth}{J R R R R R R R} \hline\hline "') postfoot(`"\hline\hline \end{tabulary}}"') b(2) nonumbers 

estpost summarize extpeff  polcare peprpres_rev  
esttab using "$erg\Appendix\Descriptives_DepVars_Extpeff.tex" , cell((count mean(fmt(2)) sd(fmt(2)) min max)) label replace  prehead(`"{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabulary}{\textwidth}{J R R R R R R R} \hline\hline "') postfoot(`"\hline\hline \end{tabulary}}"') b(2) nonumbers 

label var pedu3cat "Parents: occupational qualification"
label var edu3cat "Occupational qualification"

label var inc_cat "Income"
label var oesch3class "Oesch Classes"

lab def edulab 1 "basic" 2 "vocational" 3 "academic"
lab val pedu3cat edulab
lab val edu3cat edulab
lab val PEdu edulab
lab val IEdu edulab


graph drop _all
foreach var in PEdu pedu3cat IEdu edu3cat oesch3class inc_cat {
		catplot `var' ,  title("`: variable label `var''", size(small)) blabel(total, size(small)) l1title(" ") b1title(" ") recast(bar) var1opts(label(angle(30) labsize(small))) name(bar_`var') scheme(plotplain)
} 

graph combine bar_PEdu bar_pedu3cat bar_IEdu bar_edu3cat bar_oesch3class bar_inc_cat, col(2) name(indepbar) graphregion(margin(zero)) ycommon

cm2in A4 
graph display indepbar ,ysize(`r(in1)') xsize(`r(in2)') 

graph export "$erg\Appendix\Descriptives_Indepvar.pdf", replace

***********************************************************************************************************************************************************
****************************Step 0b: Descriptive Associations: EDU (indiv) - political DVs.s***************************************************************
***********************************************************************************************************************************************************


graph drop _all

foreach depvar in part1 polint peff {

reghdfe `depvar' i.IEdu,  absorb(i.year_secschool i.year i.BuLaYouth)  vce(cluster bulacohort)
margins, over(i.IEdu) post
marginsplot, recast(bar) scheme(plotplain) name(`depvar'_edu) title("") ytitle("") xtitle("") subtitle("`: var label `depvar''", size(small)) xlabel(1 "basic" 2 "vocational" 3 "academic")

reghdfe `depvar' i.edu3cat,  absorb(i.year_secschool i.year i.BuLaYouth)  vce(cluster bulacohort)
margins, over(i.edu3cat) post
marginsplot, recast(bar) scheme(plotplain) name(`depvar'_occ) title("") ytitle("") xtitle("") subtitle("`: var label `depvar''", size(small)) xlabel(1 "basic" 2 "vocational" 3 "academic")
}

graph combine part1_edu polint_edu peff_edu , ycommon col(1) name(edubar) title("Educational Degrees",size(small)) graphregion(margin(tiny)) iscale(0.75)   

graph combine part1_occ  polint_occ peff_occ, ycommon col(1) name(occbar) title("Occupational Qualification",size(small)) graphregion(margin(tiny)) iscale(0.75)  

graph combine edubar occbar, col(2) title("Average political engagement", size(medsmall)) note("Based on otherwise empty regression models with federal state, wave, and school cohort fixed effects.", size(tiny)) graphregion(margin(tiny)) name(descbar)

cm2in A4 
graph display descbar ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Descriptive_IndividualBiv_withFE.pdf", replace 



***********************************************************************************************************************************************************
****************************Step 1: Main Analyses *********************************************************************************************************
***********************************************************************************************************************************************************

use "Allbus_bulayouth_sec_Mar23.dta", clear

*set seed 235873274
*set seed 235873272
********************
**********
***Analyses Main Effects
**********
********************
eststo clear
graph drop _all

foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff  {
reghdfe `depvar' B_destrat_index W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_main
}


********************
**********
***Visualization Main Analyses
**********
********************
foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff  {
coefplot (`depvar'_main, aseq(Between)  drop(W_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(gs8)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs8 gs8)) ) ///
		 (`depvar'_main, aseq(Within) drop(B_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(black)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black))) ///
, legend( position(6) row(1) size(tiny))  xline(0)  scheme(plotplain) levels(90 95)  xscale(r(-0.2,0.2)) xlabel(-0.2 (0.1) 0.2) swapnames legend(off) title("`: var label `depvar''", size(small)) name(gr_`depvar') 
}


*combination of results in pdfs - Main Results

graph combine  gr_part1 gr_polint gr_peff , rows(3) scheme(plotplain) graphregion(margin(medium)) iscale(0.75)  name(main)   title("Main Effects of de-stratifying education policies on political engagement", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))


cm2in A4 
graph display main ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\MainEffects.pdf", replace 
graph export "$erg\MainEffects.svg", replace 

graph combine  gr_convp1 gr_unconvp gr_intpeff gr_extpeff , cols(2) scheme(plotplain) graphregion(margin(medium)) iscale(0.75) name(maindet) title("Main Effects of de-stratifying education policies on political engagement", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display maindet,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_Detail.pdf", replace 

********************
**********
***Analyses Moderation Effects (Individual Educational and socio-economic heterogeneity)
**********
********************

foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff  {

*i.PEdu i.pedu3cat
**moderation with respondents' educational degree
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu /// 
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_edu
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_mod_W_edu

**moderation with respondents' occupational qualification
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///  
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_occ
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_mod_W_occ
}



********************
**********
****Visualization of Moderation Effects
**********
********************

***
*Marginal Effects
***
graph drop _all
foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff {
coefplot ///
(`depvar'_mod_W_edu,  label(Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'_mod_W_occ,  label(Occ. Qualification)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) ) ///
,  legend(position(6) row(1) size(vsmall)  )  xline(0)  scheme(plotplain) title("`: var label `depvar''", size(small)) ///
name(mod_`depvar')  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. 1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95)  xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

*combination of results in pdfs - Main Results - Moderation

grc1leg mod_part1 mod_polint mod_peff , rows(3) scheme(plotplain) imargin(vsmall) iscale(0.7) name(main_mod) title("Cross-level interaction: effects of de-stratifying education policies" "on political engagement among different educational groups", size(vsmall))   note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_mod ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Moderation.pdf", replace 
graph export "$erg\Moderation.svg", replace 

*combination of results in pdfs - Subindices for Appendix - Moderation

grc1leg mod_convp1 mod_unconvp , rows(2) scheme(plotplain) imargin(vsmall) iscale(0.7) name(mod_detpart) title("Cross-level interaction: (within) effects of de-stratifying education policies" "on political engagement among different educational groups", size(vsmall))   note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display mod_detpart ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Detail_Part.pdf", replace 

grc1leg mod_intpeff mod_extpeff , rows(2) scheme(plotplain) imargin(vsmall) iscale(0.7) name(mod_detpeff) title("Cross-level interaction: effects of de-stratifying education policies" "on political engagement among different educational groups", size(vsmall))   note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))



cm2in A4 
graph display mod_detpeff ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Detail_Peff.pdf", replace 


***********************************************************************************************************************************************************
****************************Step 1b: main analyses as table*****************************************************************************************
***********************************************************************************************************************************************************

*tabular results participation (main effects)
esttab  part1_main using "$erg\Appendix\TabularResults_Participation_Main.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3)   stats(N  r2, fmt(0  3) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}")) label  nonumbers  alignment (S S) nogaps compress /// 
mtitles(" ") mgroups("Main Effects: Political Participation" , ///
pattern(1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace nobaselevels  addnotes("School cohort and Allbus wave fixed effects included.")
 
*tabular results pol. interest (main effects)
esttab  polint_main  using "$erg\Appendix\TabularResults_Interest_Main.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3)    stats(N r2, fmt(0  3) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}" )) label  nonumbers  alignment (S S) nogaps compress /// 
mtitles(" ") mgroups( "Main Effects: Political Interest", ///
pattern(1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace  nobaselevels  addnotes("School cohort and Allbus wave fixed effects included.")

 *tabular results efficacy (main effects)
esttab  peff_main  using "$erg\Appendix\TabularResults_Efficacy_Main.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3)  stats(N r2, fmt(0 3 ) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}" )) label  nonumbers  alignment (S S) nogaps compress /// 
mtitles(" ") mgroups( "Main Effects: Political Efficacy" , ///
pattern(1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace nobaselevels  addnotes("School cohort and Allbus wave fixed effects included.")


*tabular results participation (moderation effects)
esttab  part1_mod_edu  part1_mod_occ using "$erg\Appendix\TabularResults_Participation_Mod.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3)   stats(N r2, fmt(0  3) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}" )) label  nonumbers  alignment (S S ) nogaps compress wide  /// 
mtitles( "Edu. Degrees" "Occ. Quali." ) mgroups("Moderation Effects: Political Participation" , ///
pattern(1 0   ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace nobaselevels nonotes addnotes("Standard errors cluster by federal state-specific school cohorts in parentheses. \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "School cohort and Allbus wave fixed effects included. Occ. Quali = Occupational Qualification")
 
*tabular results pol. interest (moderation effects)
esttab polint_mod_edu polint_mod_occ  using "$erg\Appendix\TabularResults_Interest_Mod.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3)    stats(N r2, fmt(0  3) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}" )) label  nonumbers  alignment (S S ) nogaps compress wide /// 
mtitles("Edu. Degrees" "Occ. Quali" ) mgroups( "Moderation Effects: Political Interest", ///
pattern(1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace nobaselevels nonotes addnotes("Standard errors cluster by federal state-specific school cohorts in parentheses. \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "School cohort and Allbus wave fixed effects included. Occ. Quali = Occupational Qualification")

 *tabular results efficacy (moderation effects)
esttab  peff_mod_edu peff_mod_occ  using "$erg\Appendix\TabularResults_Efficacy_Mod.tex" ,  /// 
star(+ 0.10 * 0.05 ** 0.01 *** 0.001) se(3) b(3) stats(N r2, fmt(0  3) labels(`"Obs."' `"R$^2$"') ///
layout("\multicolumn{1}{c}{@}" )) label  nonumbers  alignment (S S ) nogaps compress wide /// 
mtitles("Edu. Degrees" "Occ. Quali" ) mgroups( "Moderation Effects: Political Efficacy" , ///
pattern(1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span ) ///
 replace  nobaselevels nonotes addnotes("Standard errors cluster by federal state-specific school cohorts in parentheses. \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)" "School cohort and Allbus wave fixed effects included. Occ. Quali = Occupational Qualification") noisily
 
 estwrite _all using "$erg\EstimatesMainAnalysis.sters" , replace

***********************************************************************************************************************************************************
****************************Step 1b: main analyses as marginal predictions*********************************************************************************
***********************************************************************************************************************************************************

***
*Marginal Predictions
***
graph drop _all
fre IEdu
foreach depvar in part1 polint peff  {
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu /// 
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
sum W_destrat_index
margins, over(IEdu)  at(c.W_destrat_index=(`r(min)' (0.1) `r(max)')) level(90)
marginsplot,  title("`: var label `depvar''", size(small)) xscale(r(-0.5,0.55)) xlabel(-0.5 (0.2) 0.5)  name(pred_`depvar'_edu) legend(position(6) row(1) size(vsmall)) plot1opts(lcol(black) mcol(black) msymbol(circle) lpattern(solid) ) plot2opts(lcol(gs9) mcol(gs9) msymbol(triangle_hollow) lpattern(dash) ) plot3opts(lcol(black) mcol(black) msymbol(square) lpattern(solid) ) ci1opt(lcol(black)) ci2opt(lcol(gs9)) ci3opt(lcol(black) ) scheme(plotplain) ytitle(Predicted Values, size(vsmall)) yscale(r(0.1,0.7)) ylabel(0.1 (0.2) 0.7) xtitle(,size(vsmall))

**moderation with respondents' occupational qualification
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///  
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
sum W_destrat_index
margins, over(edu3cat)  at(c.W_destrat_index=(`r(min)' (0.1) `r(max)')) level(90)
marginsplot,  title("`: var label `depvar''", size(small)) xscale(r(-0.5,0.55)) xlabel(-0.5 (0.2) 0.5)  name(pred_`depvar'_occ) legend(position(6) row(1) size(vsmall)) plot1opts(lcol(black) mcol(black) msymbol(circle) lpattern(solid) ) plot2opts(lcol(gs9) mcol(gs9) msymbol(triangle_hollow) lpattern(dash) ) plot3opts(lcol(black) mcol(black) msymbol(square) lpattern(solid) ) ci1opt(lcol(black)) ci2opt(lcol(gs9)) ci3opt(lcol(black) ) scheme(plotplain) ytitle(Predicted Values, size(vsmall)) yscale(r(0.1,0.7)) ylabel(0.1 (0.2) 0.7) xtitle(,size(vsmall))
}

grc1leg  pred_part1_edu  pred_polint_edu  pred_peff_edu , cols(1) scheme(plotplain) graphregion(margin(medium)) name(pred_edu)  iscale(0.75) title("Predicted values of political engagement" "by individual educational degrees and (de-)stratifying policies" "based on within-component of cross-level interaction", size(small)) graphregion(margin(zero)) plotregion(margin(tiny)) imargin(tiny)

cm2in A4 
graph display pred_edu ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Prediction_Edu.pdf", replace 
 

grc1leg   pred_part1_occ  pred_polint_occ  pred_peff_occ, cols(1) scheme(plotplain) graphregion(margin(medium)) name(pred_occ)  iscale(0.75) title("Predicted values of political engagement" "by individual occupational qualification and (de-)stratifying policies" "based on within-component of cross-level interaction", size(small)) graphregion(margin(zero)) plotregion(margin(tiny)) imargin(tiny)


cm2in A4 
graph display pred_occ ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Prediction_Occ.pdf", replace 
 
***********************************************************************************************************************************************************
****************************Step 2: Additional Dependent Variables*****************************************************************************************
***********************************************************************************************************************************************************
eststo clear
graph drop _all
********************
**********
***Analyses Main Effects
**********
********************

*part 1 = opinion+elect+discuss+initiv+wrkprty+unlawdem+demo+abstain+protvote+petition
*peff = peactgrp_rev+pecomplx + peknowl +polcare+peprpres_rev

foreach depvar in opinion elect discuss initiv wrkprty unlawdem demo abstain protvote petition peactgrp_rev pecomplx peknowl polcare peprpres_rev  {
reghdfe `depvar' B_destrat_index W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_main
}

********************
**********
***Visualization Main Analyses
**********
********************

*participation + external efficacy
foreach depvar in opinion elect discuss initiv wrkprty unlawdem demo abstain protvote petition polcare peprpres_rev peactgrp_rev pecomplx peknowl{
coefplot (`depvar'_main, aseq(Between) label(Basic Model) drop(W_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(gs8)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs8 gs8)) ) ///
		 (`depvar'_main, aseq(Within) label(Basic Model) drop(B_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(black)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black))) ///
, legend( position(6) row(1) size(tiny))  xline(0)  scheme(plotplain) levels(90 95)  xscale(r(-0.2,0.2)) xlabel(-0.2 (0.1) 0.2) swapnames legend(off) title("`: var label `depvar''", size(small)) name(gr_`depvar')
}



*combination of results in pdfs - Main Results
*Conventional Part
graph combine gr_elect gr_wrkprty gr_abstain gr_protvote  , rows(2) scheme(plotplain) graphregion(margin(medium)) iscale(0.75)  name(mainpart)   title("Robustness check: Single variables: Conventional participation", size(small)) subtitle("Main Effects of de-stratifying education policies on political engagement ", size(vsmall)) note("For each dependent variable positive coefficients show increased participation" "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))





cm2in A4 
graph display mainpart,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_SingleVars_Convp.pdf", replace 

*Unconventional Part
graph combine   gr_opinion gr_discuss gr_initiv gr_unlawdem gr_demo gr_petition , rows(3) scheme(plotplain) graphregion(margin(medium)) iscale(0.75) name(mainunc)    title("Robustness check: Single variables: Unconventional participation", size(small)) subtitle("Main Effects of de-stratifying education policies on political engagement", size(vsmall)) note("For each dependent variable positive coefficients show increased participation." "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display mainunc ,ysize(`r(in1)') xsize(`r(in2)')

graph export "$erg\Appendix\MainEffects_SingleVars_Unconvp.pdf", replace 

*Internal Efficacy
graph combine   gr_peactgrp_rev gr_pecomplx gr_peknowl, rows(3) scheme(plotplain) graphregion(margin(medium)) iscale(0.75)  name(maineff)   title("Robustness check: Single variables: Internal efficacy", size(small)) subtitle("Main Effects of de-stratifying education policies on political engagement", size(vsmall)) note("For each dependent variable positive coefficients show increased efficacy." "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display maineff ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_SingleVars_Inteff.pdf", replace 

*External Efficacy
graph combine  gr_polcare gr_peprpres_rev, rows(2) scheme(plotplain) graphregion(margin(medium)) iscale(0.75)   name(mainext) title("Robustness check: Single variables: External efficacy", size(small)) subtitle("Main Effects of de-stratifying education policies on political engagement", size(vsmall))  note("For each dependent variable positive coefficients show increased efficacy." "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display mainext ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_SingleVars_Exteff.pdf", replace 


********************
**********
***Analyses Moderation Effects (Individual Education)
**********
********************
eststo clear
foreach depvar in opinion elect discuss initiv wrkprty unlawdem demo abstain protvote petition peactgrp_rev pecomplx peknowl polcare peprpres_rev  {

**moderation with respondents' educational degree
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_mod_W_edu

**moderation with respondents' occupational qualification
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_mod_W_occ

}



********************
**********
****Visualization of Moderation Effects
**********
********************

*participation & external efficacy
foreach depvar in opinion elect discuss initiv wrkprty unlawdem demo abstain protvote petition polcare peprpres_rev  peactgrp_rev pecomplx peknowl  {
coefplot ///
(`depvar'_mod_W_edu,  label(Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'_mod_W_occ,  label(Occ. Qualification)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) ) ///
,  legend(position(6) row(1) size(vsmall)  )  xline(0)  scheme(plotplain) title("`: var label `depvar''", size(small)) ///
name(mod_`depvar')  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. 1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95)  xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

*combination of results in pdfs - Main Results
*Conventional Part

grc1leg mod_elect mod_wrkprty mod_abstain mod_protvote , rows(2) scheme(plotplain) imargin(zero) iscale(0.7) name(mod_single_convp) title("Robustness check: Single variables: Conventional participation", size(vsmall))  subtitle("Cross-level interaction: effects of de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(vsmall))   note("For each dependent variable positive coefficients show increased participation" "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display mod_single_convp ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_SingleVars_Convp.pdf", replace 

*Unconventional Part
*opinion discuss initiv unlawdem demo  petition

grc1leg mod_opinion mod_discuss mod_initiv mod_unlawdem mod_demo mod_petition , rows(3) scheme(plotplain) imargin(zero) iscale(0.7) name(mod_single_unconvp) title("Robustness check: Single variables: Unconventional participation", size(small)) subtitle("Cross-level interaction: effects of de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(vsmall))   note("For each dependent variable positive coefficients show increased participation" "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))



cm2in A4 
graph display mod_single_unconvp ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_SingleVars_Unconvp.pdf", replace 

*Internal Efficacy
grc1leg   mod_peactgrp_rev mod_pecomplx  mod_peknowl, rows(3) scheme(plotplain) imargin(zero) iscale(0.7)  name(maininteff)   title("Robustness check: Single variables: Internal efficacy", size(small)) subtitle("Cross-level interaction: effects of de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(small)) note("For each dependent variable positive coefficients show increased efficacy" "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display maininteff ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_SingleVars_Inteff.pdf", replace 

*External Efficacy
grc1leg  mod_polcare mod_peprpres_rev , rows(2) scheme(plotplain) imargin(vsmall) iscale(0.7)   name(mainexteff) title("Robustness check: Single variables: External efficacy", size(small)) subtitle("Cross-level interaction: effects of de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(small)) note("For each dependent variable positive coefficients show increased efficacy" "Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display mainexteff ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_SingleVars_Exteff.pdf", replace 


********************************************************************************
********************************************************************************
***Step 3: Analyses with individual destratifying policies + binary index*******
********************************************************************************
********************************************************************************
eststo clear
graph drop _all

estread _all using "$erg\EstimatesMainAnalysis.sters" 

********************
**********
***Analyses Main Effects
**********
********************

graph drop _all

foreach depvar in part1 polint peff {
	foreach indepvar in mod_edsys duration_prim  compr_school  share_gym  {
		reghdfe `depvar' B_`indepvar' W_`indepvar' c.age c.age_sq i.female i.migrabg  i.PEdu i.pedu3cat c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet , absorb(i.year_secschool i.year) vce(cluster bulacohort)
		eststo `depvar'`indepvar'
}
}



********************
**********
***Visualization Main Analyses
**********
********************

graph drop _all

foreach depvar in part1 polint peff {
coefplot ///
		 (`depvar'_main, aseq(Between) label("Original Results") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left*) mcolor(red)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(red red)) ) ///
		 (`depvar'_main, aseq(Within) label("Original Results") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(red)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(red red))) ///
		 (`depvar'mod_edsys, aseq(Between) label("`: var label mod_edsys'") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(black)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black)) ) ///
		 (`depvar'mod_edsys, aseq(Within) label("`: var label mod_edsys'") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(black)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black))) ///
		 (`depvar'duration_prim, aseq(Between) label("`: var label duration_prim'") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(triangle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'duration_prim, aseq(Within) label("`: var label duration_prim'") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(triangle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
		 (`depvar'compr_school, aseq(Between) label("`: var label compr_school'") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(square)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'compr_school, aseq(Within) label("`: var label compr_school'") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(square)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
		 (`depvar'share_gym, aseq(Between) label("`: var label share_gym'") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'share_gym, aseq(Within) label("`: var label share_gym'") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
, legend(position(6) cols(2)  colfirst size(tiny))  xline(0)  scheme(plotplain) levels(90 95)  xscale(r(-0.2,0.2)) xlabel(-0.2 (0.1) 0.2) swapnames  title("`: var label `depvar''", size(small)) name(gr_`depvar') coeflabels(,wrap(25)) p2(nokey) p4(nokey) p6(nokey) p8(nokey) p10(nokey) p12(nokey) p14(nokey) p16(nokey) p18(nokey) p20(nokey) 
}


*combination of results in pdfs - Main Results

grc1leg  gr_part1 gr_polint gr_peff , rows(3) scheme(plotplain) graphregion(margin(tiny)) iscale(0.75)  name(main)   title("Main Effects of single de-stratifying education policies on political engagement", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_SinglePolicyIndicators.pdf", replace 


********************
**********
***Analyses Moderation Effects (Individual Education)
**********
********************
graph drop _all
eststo clear

estread _all using "$erg\EstimatesMainAnalysis.sters" 

foreach depvar in part1 polint peff {	
	foreach indepvar in mod_edsys duration_prim  compr_school  share_gym   {

**moderation with respondents' educational degree
reghdfe `depvar' B_`indepvar' W_`indepvar' ///
			   i.IEdu ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.IEdu#c.B_`indepvar'  i.IEdu#c.W_`indepvar' , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_`indepvar') over(i.IEdu) post
eststo `depvar'`indepvar'edu

**moderation with respondents' occupational qualification
reghdfe `depvar' B_`indepvar' W_`indepvar' ///
			   i.edu3cat ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.edu3cat#c.B_`indepvar'  i.edu3cat#c.W_`indepvar' , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_`indepvar') over(i.edu3cat) post
eststo `depvar'`indepvar'occ

}
}




********************
**********
****Visualization of Moderation Effects
**********
********************

graph drop _all

foreach depvar in part1 polint peff {

coefplot ///
(`depvar'_mod_W_edu,  label(Orig. Results) aseq( Edu. Degree)  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.4) ) ///
(`depvar'mod_edsysedu,  label(`: var label mod_edsys') aseq(Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.2) ) ///
(`depvar'share_gymedu,  label(`: var label share_gym') aseq(Edu. Degree)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle)   ) ///
(`depvar'compr_schooledu,  label(`: var label compr_school')  aseq(Edu. Degree)  mcolor(gs4) ciopts(lcol(gs4 gs4) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) offset(-0.2) ) ///
(`depvar'duration_primedu,  label(`: var label duration_prim') aseq(Edu. Degree)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) offset(-0.4) ) ///
(`depvar'_mod_W_occ,  label(Orig. Results) aseq(Occ. Quali.)  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.4)) ///
(`depvar'mod_edsysocc,  label(`: var label mod_edsys') aseq(Occ. Quali.)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.2) ) ///
(`depvar'share_gymocc,  label(`: var label share_gym') aseq(Occ. Quali.)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'compr_schoolocc,  label(`: var label compr_school') aseq(Occ. Quali.)  mcolor(gs4) ciopts(lcol(gs4 gs4) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) offset(-0.2) ) ///
(`depvar'duration_primocc,  label(`: var label duration_prim') aseq(Occ. Quali.)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) offset(-0.4) )  ///
, title("`: var label `depvar''", size(small))  xline(0)  scheme(plotplain)  ///
name(mod_`depvar')  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. 1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95) legend(position(6) col(3) size(tiny) ) swapnames  p6(nokey) p7(nokey) p8(nokey) p9(nokey) p10(nokey) p11(nokey) p12(nokey) p13(nokey) p14(nokey) p15(nokey)  coeflabels(,wrap(12)) xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

*combination of results in pdfs - Main Results - Moderation

grc1leg  mod_part1 mod_polint mod_peff, rows(3) scheme(plotplain) imargin(zero) iscale(0.5) name(main_part_mod)   title("Cross-level interaction: effects of single de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(vsmall))  note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_part_mod ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Main_SinglePolicyIndicators.pdf", replace 

***********************************************************************************************************************************************************
****************************Step 4: Main Moderation Analyses with additional societal groups***************************************************************
***********************************************************************************************************************************************************

eststo clear
graph drop _all

********************
**********
***Analyses Moderation Effects (Individual Educational and socio-economic heterogeneity)
**********
********************

foreach depvar in part1 polint peff {

**moderation with parents educational degree
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.PEdu ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.PEdu#c.B_destrat_index  i.PEdu#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_parent_edu
*Margins Within
margins, dydx(c.W_destrat_index) over(i.PEdu) post
eststo `depvar'_mod_W_paredu

**moderation with parents occupational qualification
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.pedu3cat#c.B_destrat_index  i.pedu3cat#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_parent_occ
*Margins Within
margins, dydx(c.W_destrat_index) over(i.pedu3cat) post
eststo `depvar'_mod_W_parocc


**moderation with respondents' oesch class
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.oesch3class ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.oesch3class#c.B_destrat_index  i.oesch3class#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_oesch
*Margins Within
margins, dydx(c.W_destrat_index) over(i.oesch3class) post
eststo `depvar'_mod_W_oesch

**moderation with respondents' income
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.inc_cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.inc_cat#c.B_destrat_index  i.inc_cat#c.W_destrat_index , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_inc
*Margins Within
margins, dydx(c.W_destrat_index) over(i.inc_cat) post
eststo `depvar'_mod_W_inc

}



********************
**********
****Visualization of Moderation Effects
**********
********************

***
*Marginal Effects
***
graph drop _all
foreach depvar in part1 polint peff {
coefplot ///
(`depvar'_mod_W_paredu,  label(Parental Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle_hollow) ) ///
(`depvar'_mod_W_parocc,  label(Parental Occ. Qualification)  mcolor(gs9) ciopts(lcol(gs9 gs9) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond_hollow) ) ///
(`depvar'_mod_W_oesch,  label(Repondents' Social Class)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle_hollow) ) ///
(`depvar'_mod_W_inc,  label(Repondents' Income)  mcolor(gs3) ciopts(lcol(gs3 gs3) recast(rcap rcap)  lwidth(medium thin)) msymbol(square_hollow) ) ///
,  legend(position(6) row(1) size(tiny)  )  xline(0)  scheme(plotplain) title("`: var label `depvar''", size(small)) ///
name(mod_`depvar')  rename(1.PEdu = Basic/Low 2.PEdu= Voc./Middle 3.PEdu= Acad./High 1.pedu3cat = Basic/Low 2.pedu3cat = Voc./Middle 3.pedu3cat = Acad./High 1.oesch3class= Basic/Low 2.oesch3class= Voc./Middle 3.oesch3class= Acad./High 1.inc_cat = Basic/Low 2.inc_cat = Voc./Middle 3.inc_cat = Acad./High) levels(90 95) xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}


*combination of results in pdfs - Main Results - Moderation

grc1leg  mod_part1 mod_polint mod_peff , rows(3) scheme(plotplain) imargin(vsmall) iscale(0.5) name(main_mod) title("Cross-level interaction: effects of de-stratifying education policies" "on political engagement among different societal groups", size(vsmall))   note("Models include age, age^2, gender and German nationalityas individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)" "Models for social class also include parents' educational and occupational qualification as individual-level controls" , size(tiny))

cm2in A4 
graph display main_mod ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_ParOcc_Class.pdf", replace 


***********************************************************************************************************************************************************
****************************Step 4: Main Analyses with alternative modelling strategies********************************************************************
***********************************************************************************************************************************************************

eststo clear
graph drop _all

estread _all using "$erg\EstimatesMainAnalysis.sters" 

********************
**********
***Analyses Main Effects
**********
********************

foreach depvar in part1 polint peff {
	***Multilevel 
	mixed `depvar' B_destrat_index W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat i.year_secschool i.year c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
		, || BuLaYouth: , reml
	eststo `depvar'_main_ml
	***FE
	reghdfe `depvar' W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat c.W_alo c.W_leftcabinet , absorb(i.year_secschool i.year i.BuLaYouth) vce(cluster bulacohort)
	eststo `depvar'_main_fe
	***FEIS
	reghdfe `depvar' W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat c.W_alo c.W_leftcabinet  , absorb(i.year_secschool i.year i.BuLaYouth##c.year_secschool) vce(cluster bulacohort)
	eststo `depvar'_main_feis
	***Controlling for time-varying econ and pol factors
	reghdfe `depvar' B_destrat_index W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat  ///
	B_alo W_alo B_leftvote W_leftvote ///
	, absorb(i.year_secschool i.year) vce(cluster bulacohort)
	eststo `depvar'_main_tv
}


********************
**********
***Visualization Main Analyses
**********
********************
graph drop _all

foreach depvar in part1 polint peff {
coefplot ///
		 (`depvar'_main, aseq(Between) label(Original Results) drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left*) mcolor(red)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(red red)) ) ///
		 (`depvar'_main, aseq(Within) label(Original Results) drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left*) mcolor(red)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(red red))) ///
		 (`depvar'_main_fe, aseq(Between) label("State FE") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(black)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black)) ) ///
		 (`depvar'_main_fe, aseq(Within) label("State FE") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(black)  msymbol(diamond)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black))) ///
		 (`depvar'_main_feis, aseq(Between) label("State FE & State-Specific Slopes") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *alo* *left* ) mcolor(gs6)  msymbol(triangle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'_main_feis, aseq(Within) label("State FE & State-Specific Slopes") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *oesch* *inc* *alo* *left*) mcolor(gs6)  msymbol(triangle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
		 (`depvar'_main_tv, aseq(Between) label("Left Vote Share") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu*  *alo* *leftvote* *leftcabinet* *alo* *left*) mcolor(gs6)  msymbol(square)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'_main_tv, aseq(Within) label("Left Vote Share") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu*  *alo* *leftvote* *leftcabinet* *alo* *left*) mcolor(gs6)  msymbol(square)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
		 (`depvar'_main_ml, aseq(Between) label("2-level model") drop(W_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *oesch* *inc* *alo* *left*) mcolor(gs6)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6)) ) ///
		 (`depvar'_main_ml, aseq(Within) label("2-level model") drop(B_*  _cons *age* *year* *female* *migrabg* *PEdu* *pedu3cat* *edu* *Edu* *oesch* *inc* *alo* *left*) mcolor(gs6)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs6 gs6))) ///
, legend(position(6) cols(2)  colfirst size(tiny))  xline(0)  scheme(plotplain) levels(90 95)  xscale(r(-0.2,0.2)) xlabel(-0.2 (0.1) 0.2) swapnames  title("`: var label `depvar''", size(small)) name(gr_`depvar') coeflabels(,wrap(25))  p1(nokey) p3(nokey) p5(nokey) p7(nokey) p9(nokey) p11(nokey) p13(nokey) p15(nokey) p17(nokey) p19(nokey)
}

*


*combination of results in pdfs - Main Results

grc1leg  gr_part1 gr_polint gr_peff , rows(3) scheme(plotplain) graphregion(margin(tiny)) iscale(0.75)  name(main)   title("Main Effects of single de-stratifying education policies on political engagement" "Different Modelling Strategies", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_Repl.pdf", replace 


********************
**********
***Analyses Moderation Effects (Individual Education)
**********
********************

fre BuLaYouth
fre W_destrat_index

foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff {
foreach societalvar in IEdu edu3cat {
	***Multilevel 
	mixed `depvar' B_destrat_index W_destrat_index /// 
	i.`societalvar' ///
	c.age c.age_sq i.female i.migrabg  ///
	i.PEdu i.pedu3cat ///
	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
	i.`societalvar'#c.B_destrat_index  i.`societalvar'#c.W_destrat_index ///
	i.year_secschool i.year ///
	, || BuLaYouth: i.`societalvar' , reml
	*Margins Within
	margins, dydx(c.W_destrat_index) over(i.`societalvar') post
	eststo `depvar'`societalvar'ml

	***FE
	reghdfe `depvar' W_destrat_index ///
	i.`societalvar' ///
	c.age c.age_sq i.female i.migrabg  ///
	i.PEdu i.pedu3cat ///
	c.W_alo c.W_leftcabinet ///
	i.`societalvar'#c.W_destrat_index ///
	, absorb(i.year_secschool i.year i.BuLaYouth) vce(cluster bulacohort)
	*Margins Within
	margins, dydx(c.W_destrat_index) over(i.`societalvar') post
	eststo `depvar'`societalvar'fe
	
	***FEIS
	reghdfe `depvar' W_destrat_index ///
	i.`societalvar' ///
	i.PEdu i.pedu3cat ///
	c.age c.age_sq i.female i.migrabg  ///
	c.W_alo c.W_leftcabinet ///
	i.`societalvar'#c.W_destrat_index	, absorb(i.year_secschool i.year i.BuLaYouth##c.year_secschool) vce(cluster bulacohort)
	*Margins Within
	margins, dydx(c.W_destrat_index) over(i.`societalvar') post
	eststo `depvar'`societalvar'feis

	***Controlling for time-varying econ and pol factors
	reghdfe `depvar' B_destrat_index W_destrat_index ///
	i.`societalvar' ///
	i.PEdu i.pedu3cat ///
	c.age c.age_sq i.female i.migrabg  ///
	i.`societalvar'#c.B_destrat_index  i.`societalvar'#c.W_destrat_index ///
	c.B_alo c.W_alo c.B_leftvote c.W_leftvote ///
	, absorb(i.year_secschool i.year) vce(cluster bulacohort)
	*Margins Within
	margins, dydx(c.W_destrat_index) over(i.`societalvar') post
	eststo `depvar'`societalvar'tv

}
}

********************
**********
****Visualization of Moderation Effects
**********
********************

*test

graph drop _all

foreach depvar in part1 convp1 unconvp polint peff intpeff extpeff {
coefplot ///
(`depvar'_mod_W_edu,  label(Orig. Results) aseq( Edu. Degree)  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.4) ) ///
(`depvar'IEdufe,  label("State FE") aseq(Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.2) ) ///
(`depvar'IEdufeis,  label("State FE & State-Specific Slopes") aseq(Edu. Degree)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle)   ) ///
(`depvar'IEdutv,  label("Left Vote Share")  aseq(Edu. Degree)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) offset(-0.2) ) ///
(`depvar'IEduml,  label("3-level model") aseq(Edu. Degree)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) offset(-0.4) ) ///
(`depvar'_mod_W_occ,  label(Orig. Results) aseq(Occ. Quali.)  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.4)) ///
(`depvar'edu3catfe,  label("State FE") aseq(Occ. Quali.)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) offset(0.2) ) ///
(`depvar'edu3catfeis,  label("State FE & State-Specific Slopes") aseq(Occ. Quali.)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'edu3cattv,  label("Left Vote Share") aseq(Occ. Quali.)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) offset(-0.2) ) ///
(`depvar'edu3catml,  label("3-level model") aseq(Occ. Quali.)  mcolor(gs6) ciopts(lcol(gs6 gs6) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) offset(-0.4) )  ///
, title("`: var label `depvar''", size(small))  xline(0)  scheme(plotplain)  ///
name(mod_`depvar')  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. 1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95) legend(position(6) col(3) size(tiny) ) swapnames  p6(nokey) p7(nokey) p8(nokey) p9(nokey) p10(nokey)  coeflabels(,wrap(12)) xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}




*combination of results in pdfs - Main Results - Moderation
*graphregion(margin(tiny)) iscale(0.75)
grc1leg  mod_part1 mod_polint mod_peff, rows(3) scheme(plotplain) imargin(zero) iscale(0.5) name(main_mod)   title("Cross-level interaction: effects of single de-stratifying education policies (within effects)" "on political engagement among different educational groups", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_mod ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Main_Repl.pdf", replace 


***********************************************************************************************************************************************************
****************************Step 6b: Cross-Level Interaction with Individual Level confounding and mediation***************************************************************
***********************************************************************************************************************************************************

graph drop _all
eststo clear

foreach depvar in part1 polint peff {

***
**for respondents' educational degree
***

*with demographic controls + parents edu & occ (orig)
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_edu_CLI0

*with demographic controls + parents edu & occ
*and mediation: occupational quali
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   i.edu3cat ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_edu_CLI1

*with demographic controls + parents edu & occ
*and mediation: occupational quali + class
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   i.edu3cat i.oesch3class ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_edu_CLI2

*with demographic controls + parents edu & occ
*and mediation: occupational quali + class + income
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   i.edu3cat i.oesch3class i.inc_cat ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_edu_CLI3

***
**for respondents' occupational qualification
***
*confounding 2: parents edu + parents occ
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_occ_CLI0

*confounding 3: parents edu + parents occ + respondents edu
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat i.IEdu ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_occ_CLI1

*confounding + mediation 1: parents edu + parents occ + respondents edu + class
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat i.IEdu ///
			   i.oesch3class ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_occ_CLI2

*confounding + mediation 2: parents edu + parents occ + respondents edu + class + income
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   i.PEdu i.pedu3cat i.IEdu ///
			   i.oesch3class i.inc_cat ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   , absorb(i.year_secschool i.year) vce(cluster bulacohort)
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_occ_CLI3

}



********************
**********
****Visualization of Moderation Effects
**********
********************

*test

graph drop _all

foreach depvar in part1 polint peff {
coefplot ///
(`depvar'_edu_CLI0,  label("M0: Orig Results")  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'_edu_CLI1,  label("M1: M0b + R's Occ. Quali.") mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) ) ///
(`depvar'_edu_CLI2,  label("M2: M1b + Class") mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) ) ///
(`depvar'_edu_CLI3,  label("M3: M2b + Income") mcolor(gs4) ciopts(lcol(gs4 gs4) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) ) ///
, title("`: var label `depvar''", size(small))  xline(0)  scheme(plotplain)  ///
name(mod_`depvar'_edu)  rename(1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95)  legend(position(6) row(1) size(tiny) )     coeflabels(,wrap(12)) xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

foreach depvar in part1 polint peff {
coefplot ///
(`depvar'_occ_CLI0,  label("M0: Orig Results")  mcolor(red) ciopts(lcol(red red) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'_occ_CLI1,  label("M1: M0b + R's Edu. Degree") mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(square) ) ///
(`depvar'_occ_CLI2,  label("M2: M1b + Class") mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) ) ///
(`depvar'_occ_CLI3,  label("M3: M2b + Income") mcolor(gs4) ciopts(lcol(gs4 gs4) recast(rcap rcap)  lwidth(medium thin)) msymbol(circle) ) ///
, title("`: var label `depvar''", size(small))  xline(0)  scheme(plotplain)  ///
name(mod_`depvar'_occ)  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. ) levels(90 95)  legend(position(6) row(1) size(tiny) )     coeflabels(,wrap(12)) xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

**Own Edu
*combination of results in pdfs - Main Results - Moderation
*graphregion(margin(tiny)) iscale(0.75)
grc1leg  mod_part1_edu mod_polint_edu mod_peff_edu, rows(3) scheme(plotplain) imargin(zero) iscale(0.5) name(main_mod_edu)   title("Cross-level interaction with respondents' educational degrees" "with multiple confounding and mediating variables", size(vsmall)) note("Models include age, age^2, gender and German nationality as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_mod_edu ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Main_CLI_edu_cntrl.pdf", replace 


**Own Occ. Quali
*combination of results in pdfs - Main Results - Moderation
*graphregion(margin(tiny)) iscale(0.75)
grc1leg  mod_part1_occ mod_polint_occ mod_peff_occ, rows(3) scheme(plotplain) imargin(zero) iscale(0.5) name(main_mod_occ)   title("Cross-level interaction with respondents' occupational qualification" "with multiple confounding and mediating variables", size(vsmall)) note("Models include age, age^2, gender and German nationality as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_mod_occ ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_Main_CLI_occ_cntrl.pdf", replace 



***********************************************************************************************************************************************************
****************************Step 7: Main Analyses for full time employees *********************************************************************************************************
***********************************************************************************************************************************************************

********************
**********
***Analyses Main Effects
**********
********************
eststo clear
graph drop _all

foreach depvar in part1 polint peff {
reghdfe `depvar' B_destrat_index W_destrat_index c.age c.age_sq i.female i.migrabg i.PEdu i.pedu3cat 	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet  if work == 1 , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_main
}


********************
**********
***Visualization Main Analyses
**********
********************
foreach depvar in part1 polint peff {
coefplot (`depvar'_main, aseq(Between)  drop(W_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(gs9)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(gs9 gs9)) ) ///
		 (`depvar'_main, aseq(Within) drop(B_*  _cons *yborn* *year* *age* *female* *migrabg* *PEdu* *pedu3cat* *alo* *left*) mcolor(black)  msymbol(circle)  ciopts( recast(rcap rcap) lwidth(medium thin)  lcol(black black))) ///
, legend( position(6) row(1) size(tiny))  xline(0)  scheme(plotplain) levels(90 95)  xscale(r(-0.2,0.2)) xlabel(-0.2 (0.1) 0.2) swapnames legend(off) title("`: var label `depvar''", size(small)) name(gr_`depvar') 
}


*combination of results in pdfs - Main Results

graph combine  gr_part1 gr_polint gr_peff , rows(3) scheme(plotplain) graphregion(margin(medium)) iscale(0.75)  name(main)   title("Main Effects of de-stratifying education policies on political engagement" "Subsample: Full-Time Employees", size(vsmall)) note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\MainEffects_EmplSample.pdf", replace 


********************
**********
***Analyses Moderation Effects (Individual Educational and socio-economic heterogeneity)
**********
********************

foreach depvar in part1 polint peff {

**moderation with respondents' educational degree
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.IEdu ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.IEdu#c.B_destrat_index  i.IEdu#c.W_destrat_index if work == 1 , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_edu
*Margins Within
margins, dydx(c.W_destrat_index) over(i.IEdu) post
eststo `depvar'_mod_W_edu

**moderation with respondents' occupational qualification
reghdfe `depvar' B_destrat_index W_destrat_index ///
			   i.edu3cat ///
			   i.PEdu i.pedu3cat ///
			   c.age c.age_sq i.female i.migrabg  ///
			   	c.B_alo c.W_alo c.B_leftcabinet c.W_leftcabinet ///
			   i.edu3cat#c.B_destrat_index  i.edu3cat#c.W_destrat_index if work == 1 , absorb(i.year_secschool i.year) vce(cluster bulacohort)
eststo `depvar'_mod_occ
*Margins Within
margins, dydx(c.W_destrat_index) over(i.edu3cat) post
eststo `depvar'_mod_W_occ

}



********************
**********
****Visualization of Moderation Effects
**********
********************

***
*Marginal Effects
***
graph drop _all
foreach depvar in part1 polint peff {

coefplot ///
(`depvar'_mod_W_edu,  label(Edu. Degree)  mcolor(black) ciopts(lcol(black black) recast(rcap rcap)  lwidth(medium thin)) msymbol(triangle) ) ///
(`depvar'_mod_W_occ,  label(Occ. Qualification)  mcolor(gs8) ciopts(lcol(gs8 gs8) recast(rcap rcap)  lwidth(medium thin)) msymbol(diamond) ) ///
,  legend(position(6) row(1) size(vsmall)  )  xline(0)  scheme(plotplain) title("`: var label `depvar''", size(small)) ///
name(mod_`depvar')  rename(1.IEdu = Basic 2.IEdu= Voc. 3.IEdu= Acad. 1.edu3cat = Basic 2.edu3cat = Voc. 3.edu3cat = Acad.) levels(90 95)  xscale(r(-0.3,0.3)) xlabel(-0.3 (0.1) 0.3)
}

*combination of results in pdfs - Main Results - Moderation

grc1leg  mod_part1 mod_polint mod_peff , rows(3) scheme(plotplain) imargin(vsmall) iscale(0.7) name(main_mod) title("Cross-level interaction: effects of de-stratifying education policies" "on political engagement among different educational groups" "Subsample: Full-Time Employees", size(vsmall))   note("Models include age, age^2, gender, German nationality, and parents' educational and occupational qualification as individual-level controls" "Models also control for wave and school cohort fixed effects and unemployment and left cabinet power (measured at the time of the educational policies)", size(tiny))

cm2in A4 
graph display main_mod ,ysize(`r(in1)') xsize(`r(in2)')
graph export "$erg\Appendix\Moderation_EmplSample.pdf", replace 


log close